import { ref } from 'vue'

export const globalToastState = ref(false)
export const params = ref({ type: 'success', title: '成功主题(带图标)', message: '庄生晓梦迷蝴蝶', position: 'top', overlay: false })

class Toast {
  success(message = '保存成功') {
    this.showToast({ message })
  }
  error(message = '保存失败') {
    this.showToast({ message, type: 'error' })
  }
  showToast(_params = { type: 'success', title: '成功主题(带图标)', message: '庄生晓梦迷蝴蝶' }) {
    Object.assign(params.value, _params)
    globalToastState.value = !globalToastState.value
  }
}

export const toastMsg = new Toast()
